package com.desire.service.sys.impl;

import com.desire.bean.sys.User;
import com.desire.bean.sys.UserBatchBean;
import com.desire.common.Base.BaseServiceImpl;
import com.desire.mapper.sys.UserMapper;
import com.desire.service.sys.UserService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @author LittleDesire
 * @description
 * @date 2022-05-06 周五 16:26
 * @since 17
 */
@Service
public class UserServiceImpl extends BaseServiceImpl<User, UserMapper> implements UserService {
    @Override
    public int batchUpdate(UserBatchBean userBatchBean) {
        Map<String, Object> map = new HashMap<>();
        if ("del".equals(userBatchBean.getCommand())) {
            // 批量删除操作
            map.put("isdel", 1);
        } else if ("disable".equals(userBatchBean.getCommand())) {
            // 批量禁用状态
            map.put("status", 2);
        } else if ("enable".equals(userBatchBean.getCommand())) {
            // 批量开启正常状态
            map.put("status", 1);
        }
        map.put("ids", userBatchBean.getIds());
        return mapper.batchUpdate(map);
    }
}
